//
//  ViewController.m
//  CSH_SDK_Deme
//
//  Created by cyancyan on 16/9/9.
//  Copyright © 2016年 cyan. All rights reserved.
//

#import "ViewController.h"
#import "AIDoorSDK.h"
#import "UIView+Toast.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UITextField *macTextField;

@end


@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];


}
- (IBAction)onTappedSend:(id)sender {
    
    
    // 34c3d2331990 -001
    // 34c3d23319ca - 测试
    
    NSString *macAddr = _macTextField.text;

    
    Byte byte_array[] = {0x0F, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0D, 0x0A};  // 临时数组

    [AIDoorSDK getEncryptByteArray:byte_array];
    
    [AIDoorSDK sendCardNo:macAddr bytes:byte_array success:^(NSString *msg) {
        
        NSLog(@"------------->%@",msg);
        
        dispatch_async(dispatch_get_main_queue(), ^{
            [[self view] makeToast:@"打卡成功"];
        });

        
    } failed:^(NSError *error) {
        
        NSLog(@"------------>打卡失败:%@: 错误码:%ld,", [error domain],(long)[error code]);
        
        dispatch_async(dispatch_get_main_queue(), ^{
            [[self view] makeToast:[error domain]];
        });
        
    }];

}

-(void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

    [_macTextField resignFirstResponder];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

@end
